
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_F_SIKKERHED_VERIFICER_SESSION]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[EBAS_F_SIKKERHED_VERIFICER_SESSION]
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE FUNCTION [DBO].[EBAS_F_SIKKERHED_VERIFICER_SESSION] (@session uniqueidentifier, @currentTime datetime)
RETURNS int
WITH ENCRYPTION	
AS
BEGIN
	DECLARE
		@result int,
		@rettighed int
/*
	IF exists(	SELECT 1 FROM EBAS_SIKKERHED_SESSION
			WHERE GUID = @session
			AND DEAKTIVERET = 0
			AND SLUT_DATO > @currentTime )
	BEGIN			
		SET @rettighed = (SELECT EBAS.DBO.EBAS_F_SIKKERHED_HENT_RETTIGHED (@session, @currentTime))		
		IF 0 < @rettighed
		BEGIN
			-- timeout is 15 minutes, period.
			UPDATE EBAS_SIKKERHED_SESSION 
			SET SLUT_DATO = DATEADD(minute, 15, @currentTime)
			WHERE GUID = @session		
		END
	END
	ELSE	
		DELETE FROM EBAS_SIKKERHED_SESSION WHERE GUID = @session		
*/

	RETURN (@result)
END
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
